package com.ctrip.study.refactor.introduceExplainingVariable;

public class Order {

	private int _quantity;

	private int _itemPrice;
	
	public Order(int quantity, int itemPrice) {
		this._quantity = quantity;
		this._itemPrice = itemPrice;
	}

	double price() {
		// price is base price - quantity discount + shipping
		return basePrice() - quantityDiscount() + shipping();
	}

	public double shipping() {
		return Math.min(basePrice() * 0.1, 100.0);
	}

	public double quantityDiscount() {
		return Math.max(0, _quantity - 500) * _itemPrice * 0.05;
	}

	public int basePrice() {
		return _quantity * _itemPrice;
	}

}
